<?php
declare (strict_types = 1);

namespace app\event;

use app\model\User;
use think\Request;
use app\model\UserLoginLog;

class UserLoginEvent
{
    public $user;
    public $ip_address;

    public function __construct(User $user, Request $request)
    {
        $this->user       = $user;
        $this->ip_address = $request->ip();

        $this->handle();
    }

    public function handle()
    {
        UserLoginLog::generateLog($this->user->id, $this->ip_address);
    }// handle() end
}
